package com.zhongzhi;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Timer;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.zhongzhi.common.Common;
import com.zhongzhi.javafx.Splash.Splash;
import com.zhongzhi.javafx.View.MenuView;
import com.zhongzhi.util.PageUtil;

import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
import lombok.extern.log4j.Log4j;

@Log4j
@SpringBootApplication
public class ZhongzhiExcavatorSinking5Application extends AbstractJavaFxApplicationSupport{

	
	public static void main(String[] args) {
		log.info("启动主程序");
		launch(ZhongzhiExcavatorSinking5Application.class, MenuView.class, new Splash(), args);
	}
	
	@Override
	public void start(Stage stage) throws Exception {
		super.start(stage);
		stage.setTitle("Doosan挖掘机下沉量监控");
		stage.initStyle(StageStyle.UNDECORATED);
		stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
			
			@Override
			public void handle(WindowEvent event) {
				Common.setEvent(event);
				PageUtil util = new PageUtil();
				util.setPage("/fxml/function/cloud.fxml", "结束程序");
				log.info("关闭程序");
				event.consume();
//				Stage window = (Stage)Common.getSp().getScene().getWindow();
//				window.close();
//				System.exit(0);
			}
		});
	}
}
